package com.hbwxz.compareprice.impl;

import com.hbwxz.compareprice.HttpRequest;
import com.hbwxz.compareprice.PlatformPriceStrategy;
import com.hbwxz.compareprice.PriceResult;
import com.hbwxz.utils.CommonUtils;
import org.springframework.stereotype.Service;

/**
 * 京东价格、折扣
 *
 * @author shenzw
 * @date 2023/12/19
 */
@Service
public class PlatformPriceJdImpl implements PlatformPriceStrategy {
    /**
     * 获取商品比价
     *
     * @param productName 商品名称
     * @return PriceResult
     */
    @Override
    public PriceResult getPriceResult(String productName) {
        CommonUtils.printThreadLog(String.format("获取京东上【%s】价格", productName));
        HttpRequest.mockCostTimeOperation();
        PriceResult tBaoPriceResult = new PriceResult()
                .setPlatform("京东")
                .setPrice(5299);
        CommonUtils.printThreadLog(String.format("京东价格为%d", 5299));
        return tBaoPriceResult;
    }

    /**
     * 获取平台折扣
     *
     * @param productName 商品名称
     * @return int
     */
    @Override
    public int getDiscountResult(String productName) {
        CommonUtils.printThreadLog(String.format("获取京东上【%s】优惠", productName));
        HttpRequest.mockCostTimeOperation();
        CommonUtils.printThreadLog(String.format("京东优惠为：%d", -150));
        return 150;
    }
}
